package books4africa

import static org.junit.Assert.*
import org.junit.*
import grails.test.*

class BooksIntegrationTests extends GrailsUnitTestCase{
	
	private Books newBook(){
		return new Books(title:"TestBook", author:"Jason Johns", minGradeLevel:"1", maxGradeLevel:"5")
	}
	
	void testFirstBook(){
		
		
		def newBook = newBook().save(failOnError:true)
		
		def foundBook = Books.get(newBook.id)
		assertEquals "TestBook", foundBook.title
	}
	
	void testCreateAndUpdate(){
		def newBook = newBook().save(failOnError:true)
		newBook.title = "testBook-Updated"
		
		newBook.save()
		
		def foundBook = Books.get(newBook.id)
		
		assertEquals "testBook-Updated", newBook.title
	}
	


   
}
